﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace web_uchet.Classes.Security
{
    public class EnterCharsProvider
    {
        private static char[] _Chars = new char[] {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
        'p','q','r','s','t','u','v','w','x','y','z',
        'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
        '1','2','3','4','5','6','7','8','9','0'};
        public static bool Validate(string UserEntered, string Encrypted)
        {
            return _3DesAlghImplem.DecryptData(
                //HttpContext.Current.Server.HtmlDecode(
                Encrypted
                //)
                ) == UserEntered;
        }
        private static Random _R=new Random();
        public static EnterCharsData GenChars()
        {
            EnterCharsData Result = new EnterCharsData();
            System.Text.StringBuilder sb = new System.Text.StringBuilder(4);
            for (int i = 0; i < 4; i++)
                sb.Append(_Chars[_R.Next(50+i)]);
            Result.Chars = sb.ToString();
            Result.Encrypted = //HttpContext.Current.Server.HtmlEncode(
                _3DesAlghImplem.EncryptData(Result.Chars)
            //)
            ;
            return Result;
        }
    }
    public class EnterCharsData
    {
        public string Chars;
        public string Encrypted;
    }
}
